package com.yxkj.syh.app.huarong.activities.creat.bank.edit;

import android.os.Bundle;

import androidx.lifecycle.Observer;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.syh.app.basic.base.BaseActivity;
import com.yxkj.syh.app.huarong.BR;
import com.yxkj.syh.app.huarong.R;
import com.yxkj.syh.app.huarong.bean.Payment;
import com.yxkj.syh.app.huarong.constants.ArouterPath;
import com.yxkj.syh.app.huarong.databinding.ActivityEditBankCardsBinding;

/**
 * 编辑银行卡 添加银行卡
 */
@Route(path = ArouterPath.EDIT_BANK_CARDS_ACTIVITY)
public class EditBankCardsActivity extends BaseActivity<ActivityEditBankCardsBinding, EditBankCardsVM> {

    @Autowired
    Payment payment;
    @Autowired
    long linkmanID;

    @Override
    protected int getContentLayout() {
        return R.layout.activity_edit_bank_cards;
    }

    @Override
    protected int getViewModelId() {
        return BR.editBankCardsVM;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        if (payment != null) {
            mViewModel.initPayment(payment);
            mVDBinding.titleView.setTitleText("编辑收款信息");
        } else {
            mVDBinding.titleView.setTitleText("添加收款信息");
        }
        mVDBinding.titleView.setLeftOnClickListener(v -> {
            finish();
        });
        mViewModel.setLinkmanID(linkmanID);
    }

    @Override
    protected void initObservers() {
        super.initObservers();
        mViewModel.mldCommit.observe(this, aBoolean -> {
            if (aBoolean){
                finish();
            }
        });
    }
}
